<style>
    a{color:#2e52b9;}
</style>
<div class="layui-fluid">
    <div class="layui-card">
        <form method="post" action="<?= $this->projectSet["url"]["list"] ?>">
            <input type="hidden" name="type_id" value="<?= isset($type_id) ? $type_id : 0; ?>">
            <div class="layui-form layui-card-header layuiadmin-card-header-auto">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <input type="text" name="cmp_name" value="<?= $cmp_name ?>" placeholder="公司名称" autocomplete="off" class="layui-input">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <div class="layui-input-inline">
                            <select name="status_id">
                                <option value="-1">使用状态</option>
                                <?php foreach ($status as $k => $v) { ?>
                                    <option value="<?= $k ?>"<?= $status_id == $k ? " selected" : ""; ?>><?= $v["name"] ?></option>
                                <?php } ?>
                            </select>
                        </div>
                    </div>

                    <div class="layui-inline">
                        <button class="layui-btn layuiadmin-btn-list customize" lay-submit lay-filter="LAY-app-contlist-search">
                            <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
                        </button>
                    </div>
                </div>
            </div>
        </form>
    </div>
    <div class="layui-card">
        <div class="layui-card-header">
            <span><?= $navName ?></span>
            <span style="float:right;">
                <a href="<?= $this->projectSet["url"]["add"] ?>&type_id=<?= $type_id ?>" class="layui-btn layui-btn-sm customize">添加</a>
            </span>
        </div>
        <div class="layui-card-body">
            <table class="layui-hide" id="table-data" lay-filter="table-data" style="overflow-x:scroll;"></table>
        </div>
    </div>
</div>
<script>
    var editUrl = "<?= $this->projectSet["url"]["edit"] ?>";
    var doDelUrl = "<?= $this->projectSet["url"]["doDel"] ?>";
    var type_id = "<?= $type_id ?>";
</script>
<script>
    layui.use(['laypage', 'layer', 'form', 'table'], function () {
        var laypage = layui.laypage,
                table = layui.table,
                frm = layui.form,
                layer = layui.layer;

        table.render({
            elem: '#table-data'
            , url: '<?= $base_url ?>'
                    //, toolbar: '#table-toolbar'
                    //, defaultToolbar: ['filter', 'exports']//['filter', 'print', 'exports']
            , title: '<?= $navName ?>'
            , size: 'sm'
            , cellMinWidth: 100
            , height: 450
            , cols: [[
                    {field: 'id', title: 'ID号', width: 80}
                    , {field: 'cmp_name', title: '公司全称', width: 200}
                    , {field: 'contacts', title: '联系人'}
                    , {field: 'tel', title: '联系电话'}
                    , {field: 'email', title: '电子邮箱'}
                    , {field: 'status_name', title: '使用状态'}
                    , {field: 'created_at_alias', title: '创建日期', width: 150}
                    , {field: 'updated_at_alias', title: '更新时间', width: 150}
                    , {
                        fixed: 'right', title: '操作', width: 120,
                        templet: function (d) {
                            var html = '';
                            html += "<a href='javascript:;' onclick='return edit(" + d.id + ")' class='layui-btn layui-btn-normal layui-btn-xs'>修改</a>";
                            html += "<a href='javascript:;' onclick='return del(" + d.id + ")' class='layui-btn layui-btn-danger layui-btn-xs'>删除</a>";
                            return html;
                        }
                    }
                ]
            ]
            , page: {//支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['count', 'prev', 'page', 'next', 'limit'] //自定义分页布局
                        //,curr: 5 //设定初始在第 5 页
                , groups: 5 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
                , limit: <?= $pageCount ?>
                , limits: [15, 30, 50, 100, 200]
                , prev: '上一页'
                , next: '下一页'
            }
        });
    });
</script>
<script src="<?= PUBLIC_URL . "/" . $this->projectSet["file"]["js"] . "/list.js?" . rand() ?>"></script>

